package com.iknow;

import com.iknow.data.Word.SentInfo;
import com.iknow.http.HttpException;
import com.iknow.http.Response;
import com.iknow.util.Loger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class WordResponse extends IKnowResponse
{
  private static final long serialVersionUID = 836677288L;
  private final String TAG = "WordResponse";
  private String audioUrl;
  private String def;
  private String key;
  private String lang;
  private Date mCreateDate;
  private boolean mIsMyWord;
  private String mMemo;
  private String pron;
  private List<Word.SentInfo> sentList;
  private List<String> suggList;
  private String userId = null;

  public WordResponse(Response paramResponse)
    throws HttpException
  {
    super(paramResponse);
    this.key = null;
    this.lang = null;
    this.audioUrl = null;
    this.pron = null;
    this.def = null;
    this.mMemo = null;
    this.suggList = new ArrayList();
    this.sentList = new ArrayList();
    JSONObject localJSONObject = paramResponse.asJSONObject();
    try
    {
      init(localJSONObject);
      return;
    }
    catch (JSONException localJSONException)
    {
      Loger.e("WordResponse", "Create QingboResponse error:" + localJSONException.getMessage());
      localJSONException.printStackTrace();
    }
  }

  public WordResponse(JSONObject paramJSONObject)
    throws HttpException
  {
    this.key = null;
    this.lang = null;
    this.audioUrl = null;
    this.pron = null;
    this.def = null;
    this.mMemo = null;
    this.suggList = new ArrayList();
    this.sentList = new ArrayList();
    try
    {
      init(paramJSONObject);
      return;
    }
    catch (JSONException localJSONException)
    {
      Loger.e("WordResponse", "Create QingboResponse error:" + localJSONException.getMessage());
      localJSONException.printStackTrace();
    }
  }

  private String getTags(JSONArray paramJSONArray)
  {
    StringBuilder localStringBuilder = new StringBuilder();
    int i = 0;
    if (i >= paramJSONArray.length())
    {
      int j = localStringBuilder.length();
      if (j > 0)
        localStringBuilder.deleteCharAt(j - 1);
      return localStringBuilder.toString();
    }
    try
    {
      localStringBuilder.append(paramJSONArray.getString(i)).append(",");
      ++i;
    }
    catch (JSONException localJSONException)
    {
      while (true)
        localJSONException.printStackTrace();
    }
  }

  private void init(JSONObject paramJSONObject)
    throws JSONException, HttpException
  {
    this.userId = paramJSONObject.getString("id");
    this.def = paramJSONObject.getString("def");
    paramJSONObject.getString("familiarity");
    paramJSONObject.getString("keyword");
    this.mMemo = paramJSONObject.getString("description");
    this.key = paramJSONObject.getString("word");
    this.pron = paramJSONObject.getString("pron");
    this.mCreateDate = parseDate(paramJSONObject.getString("record_time"), "yyyy-MM-dd HH:mm:ss");
    this.audioUrl = paramJSONObject.getString("audio_url");
    this.lang = paramJSONObject.getString("lang");
  }

  public static List<WordResponse> wordResponses(Response paramResponse)
    throws HttpException
  {
    JSONArray localJSONArray;
    try
    {
      localJSONArray = paramResponse.asJSONArray();
      ArrayList localArrayList = new ArrayList(localJSONArray.length());
      int i = 0;
      if (i >= localJSONArray.length())
        return localArrayList;
      localArrayList.add(new WordResponse(localJSONArray.getJSONObject(i)));
      ++i;
    }
    catch (JSONException localJSONException)
    {
      throw new HttpException(localJSONException);
    }
  }

  public String getAudioUrl()
  {
    return this.audioUrl;
  }

  public Date getCreateDate()
  {
    return this.mCreateDate;
  }

  public String getDef()
  {
    return this.def;
  }

  public String getKey()
  {
    return this.key;
  }

  public String getLang()
  {
    return this.lang;
  }

  public String getMemo()
  {
    return this.mMemo;
  }

  public String getPron()
  {
    return this.pron;
  }

  public List<Word.SentInfo> getSentList()
  {
    return this.sentList;
  }

  public List<String> getSuggList()
  {
    return this.suggList;
  }

  public String getUserId()
  {
    return this.userId;
  }

  public boolean isMyWord()
  {
    return this.mIsMyWord;
  }

  public void setAudioUrl(String paramString)
  {
    this.audioUrl = paramString;
  }

  public void setCreateDate(Date paramDate)
  {
    this.mCreateDate = paramDate;
  }

  public void setDef(String paramString)
  {
    this.def = paramString;
  }

  public void setIsMyWord(boolean paramBoolean)
  {
    this.mIsMyWord = paramBoolean;
  }

  public void setKey(String paramString)
  {
    this.key = paramString;
  }

  public void setLang(String paramString)
  {
    this.lang = paramString;
  }

  public void setMemo(String paramString)
  {
    this.mMemo = paramString;
  }

  public void setPron(String paramString)
  {
    this.pron = paramString;
  }

  public void setSentList(List<Word.SentInfo> paramList)
  {
    this.sentList = paramList;
  }

  public void setSuggList(List<String> paramList)
  {
    this.suggList = paramList;
  }

  public void setUserId(String paramString)
  {
    this.userId = paramString;
  }
}